home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes reversed ƒ / Four corner centered reversed.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  98 lines

  1. /**********************************************************************\
  2.  
  3. File:        Four corner centered reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 6
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short FourCornerCenteredReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* Really, this only uses one region and one CopyBits per round.  Regions don't
  34.    have to be continuous.  On each axis, on each side of the center of the screen,
  35.    there are two parts of the region which move from the corners to the center. */
  36.    
  37. pascal short FourCornerCenteredReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  38. {
  39.     RgnHandle    curregion;
  40.     int            cx,cy,lastx,lasty;
  41.     int            BlockSize, VBlockSize;
  42.     
  43.     cx = boundsRect.left + theWindowWidth / 2;
  44.     cy = boundsRect.top + theWindowHeight / 2;
  45.     BlockSize=theWindowWidth/50;
  46.     VBlockSize=theWindowHeight/50;
  47.  
  48.     curregion=NewRgn();
  49.     
  50.     lasty=theWindowHeight/2;
  51.     lastx=theWindowWidth/2;
  52.     do
  53.     {
  54.         StartTiming();
  55.         SetEmptyRgn(curregion);
  56.         MoveTo(cx,cy);
  57.         OpenRgn();              /* much much faster than 8 regions/CopyBits */
  58.             LineTo(cx-lastx,boundsRect.top);
  59.             Line(-BlockSize,0);
  60.             LineTo(cx+lastx+BlockSize,boundsRect.bottom);
  61.             Line(-BlockSize,0);
  62.             LineTo(cx,cy);
  63.             
  64.             LineTo(cx+lastx,boundsRect.top);
  65.             Line(BlockSize,0);
  66.             LineTo(cx-lastx-BlockSize,boundsRect.bottom);
  67.             Line(BlockSize,0);
  68.             LineTo(cx,cy);
  69.             
  70.             LineTo(boundsRect.right,cy-lasty);
  71.             Line(0,-VBlockSize);
  72.             LineTo(boundsRect.left,cy+lasty+VBlockSize);
  73.             Line(0,-VBlockSize);
  74.             LineTo(cx,cy);
  75.             
  76.             LineTo(boundsRect.right,cy+lasty);
  77.             Line(0,VBlockSize);
  78.             LineTo(boundsRect.left,cy-lasty-VBlockSize);
  79.             Line(0,VBlockSize);
  80.             LineTo(cx,cy);
  81.         CloseRgn(curregion);
  82.  
  83.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  84.             &boundsRect, &boundsRect, 0, curregion);
  85.         lastx-=BlockSize;
  86.         lasty-=VBlockSize;
  87.         TimeCorrection(CorrectTime);
  88.     }
  89.     while (lastx>boundsRect.left);
  90.  
  91.     CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  92.         &boundsRect, &boundsRect, 0, 0L);    /* in case we miss a few pixels */
  93.     
  94.     DisposeRgn(curregion);
  95.     
  96.     return 0;
  97. }
  98.